/**
 * 
 */
package com.ms.service.module.baccarat;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ms.game.bank.message.BankRequest;
import com.ms.game.bank.message.BankResponse;
import com.ms.game.gmtool.ISlotGameServerActionToGMTool;
import com.ms.game.slot.base.ISlotGameServerAction;
import com.ms.game.slot.base.message.SGmtoolCleanGameSeatStatusRequest;
import com.ms.game.slot.base.message.SSlotCommonDmSeatPlayerInfoRequest;
import com.ms.game.slot.base.message.SlotBasicGameMessageRequest;
import com.ms.service.error.ErrorCode;
import com.ms.service.module.account.message.SSessionCloseNotify;
import com.ms.service.module.baccarat.db.BacrActivityCombosInfoModel;
import com.ms.service.module.baccarat.message.CBacrPlayerBetRequest;
import com.ms.service.module.zone.message.SGameJackPotLockResponse;
import com.xpec.c4.game.utility.GameUtility;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.annotations.MessageType;
import com.xpec.c4.service.common.BaseMessageAction;
import com.xpec.c4.service.message.MessageAction;
import com.xpec.c4.service.module.BasicServiceModule;

/**
 * 百家樂消息接收類別
 * 
 * @author TW15010
 */
public class BacrAction extends BaseMessageAction implements ISlotGameServerAction,
ISlotGameServerActionToGMTool
{
	/** log4j object */
	private static final Log log = LogFactory.getLog(BacrAction.class);

	/**
	 * 取得收消息的 module processor instance
	 * 
	 * @return
	 */
	private BacrProcessor getProc() {
		BasicServiceModule module = getModule();
		if (!(module instanceof BacrGameModule)) {
			if (log.isErrorEnabled()) {
				log.error(GameUtility.getCurMethodName() + ": get game module type is invalid.");
			}
			return null;
		}

		BacrGameModule bacrModule = (BacrGameModule) module;

		BacrProcessor proc = bacrModule.getProc();

		return proc;
	}

	@MessageType(typeCode = MessageTypes.C_BACR_PLAYER_BET_REQUEST)
	public void recvPlayerBetRequest(CBacrPlayerBetRequest request) {
		BacrProcessor proc = getProc();
		proc.recvPlayerBetRequest(request);
	}

	@MessageType(typeCode = MessageTypes.S_BACR_DOORMAN_MACHINE_MODEL_READY)
	public void recvDoormanMachineModelReady(Object obj) {
		BacrProcessor proc = getProc();
		proc.initialGameCore();
	}
	
	@Override
	@MessageType(typeCode = MessageTypes.S_GMTOOL_CLEAN_GAME_SEAT_STATUS)
	public void revGmtoolCleanGameSeatStatus(
			SGmtoolCleanGameSeatStatusRequest request) 
	{
		getProc().revGmtoolCleanGameSeatStatus(request);
	}
	
	@Override
	@MessageType(typeCode = MessageTypes.S_SESSION_CLOSE_NOTIFY)
	public void revDisConnect(SSessionCloseNotify request) {
		getProc().revDisConnect(request);
	}
	
	@MessageType(typeCode = MessageTypes.S_BACR_START_GAME_NOTIFY)
	public void recvStartGameNotify(long waitTimeDuration) {
		getProc().recvStartGameNotify(waitTimeDuration);
	}
	
	@MessageType(typeCode = MessageTypes.S_GMTOOL_SET_BACR_ACTIVITY_COMBOS_INFO)
	public void recvGMToolSetActivityCombosInfo(BacrActivityCombosInfoModel model){
		getProc().recvGMToolUpdateActivityCombosInfo(model);
	}

	/**
	 * 轉點
	 */
	@MessageType(typeCode = MessageTypes.C_BANK_CHANGE_POINT_TO_GOLD_REQUEST)
	public void changePointToGold(BankRequest request){
		BankResponse response = new BankResponse();
		response.errorCode = ErrorCode.CANT_CHANGE_POINT_TO_GOLD;
		MessageAction.sendMessage(sessionID, MessageTypes.S_BANK_CHANGE_POINT_TO_GOLD_RESPONSE, response);
	}

	/**
	 * 包月
	 */
	@MessageType(typeCode = MessageTypes.C_BANK_MONTHLY_FEE_REQUEST)
	public void buyMonthlyFeeByPoint(Object request){
		BankResponse response = new BankResponse();
		response.errorCode = ErrorCode.CANT_MONTHLY_FEE;
		MessageAction.sendMessage(sessionID, MessageTypes.S_BANK_MONTHLY_FEE_RESPONSE, response);
	}
	
	@Override
	@MessageType(typeCode = MessageTypes.C_SLOT_COMMON_STOP_AUTO_SPIN_OPTION_REQUEST)
	public void revClientStopAutoSpinOptionQuery(Object obj) {
	}

	// ----------------↓新框架 or 牌桌類 己不使用以下函式↓----------------
	@Override
	public void revGameLeaveSeat(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}

	
	@Override
	public void revClientGameSeatVerifyBack(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void revClientSpin(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void revGameJackPotLockBack(SGameJackPotLockResponse request)
			throws NoSuchMethodException, SecurityException,
			IllegalAccessException, IllegalArgumentException,
			InvocationTargetException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void revGameHistoryRecord(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void revSeatVerifyInfoRequest(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void revSeatPlayerInfoRequest(SSlotCommonDmSeatPlayerInfoRequest request) {
		//this.getProcesser().revSeatPlayerInfoRequest(this.sessionID,request);
	}
	
	@Override
	public void revGameLeaveSeatBack(SlotBasicGameMessageRequest request) {
		
	}
	
	@Override
	public void revClientGameSeatVerify(SlotBasicGameMessageRequest request) {
		// TODO Auto-generated method stub
		
	}

	
}
